Skip to content

[ubsan_minimal] Add address argument to Android's abort message function #152419

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Aug 7, 2025

Conversation

Sharjeel-Khan
Copy link
Contributor

#152192 forgot to make the argument changes to Android code in UBsan minimal causing a build error for Android LLVM:

/b/f/w/src/git/out/llvm-project/compiler-rt/lib/ubsan_minimal/ubsan_minimal_handlers.cpp:102:3: error: no matching function for call to 'format_msg'
  102 |   format_msg(kind, caller, msg_buf, msg_buf + sizeof(msg_buf));
      |   ^~~~~~~~~~
/b/f/w/src/git/out/llvm-project/compiler-rt/lib/ubsan_minimal/ubsan_minimal_handlers.cpp:37:13:
note: candidate function not viable: requires 5 arguments, but 4 were
provided
   37 | static void format_msg(const char *kind, uintptr_t caller,
      |             ^          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   38 |                        const uintptr_t *address, char *buf,
const char *end) {

This change adds the address argument to abort_with_message just like __ubsan_report_error_fatal so it can be passed to format_msg.

llvm#152192 forgot to make the
argument changes to Android code in UBsan minimal causing a build error for Android LLVM:
/b/f/w/src/git/out/llvm-project/compiler-rt/lib/ubsan_minimal/ubsan_minimal_handlers.cpp:102:3:
error: no matching function for call to 'format_msg'
  102 |   format_msg(kind, caller, msg_buf, msg_buf + sizeof(msg_buf));
      |   ^~~~~~~~~~
/b/f/w/src/git/out/llvm-project/compiler-rt/lib/ubsan_minimal/ubsan_minimal_handlers.cpp:37:13:
note: candidate function not viable: requires 5 arguments, but 4 were
provided
   37 | static void format_msg(const char *kind, uintptr_t caller,
      |             ^          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   38 |                        const uintptr_t *address, char *buf,
const char *end) {

This change adds the address argument to abort_with_message just like
__ubsan_report_error_fatal so it can be passed to format_msg.
@llvmbot
Copy link
Member

llvmbot commented Aug 7, 2025

@llvm/pr-subscribers-compiler-rt-sanitizer

Author: Sharjeel Khan (Sharjeel-Khan)

Changes

#152192 forgot to make the argument changes to Android code in UBsan minimal causing a build error for Android LLVM:

/b/f/w/src/git/out/llvm-project/compiler-rt/lib/ubsan_minimal/ubsan_minimal_handlers.cpp:102:3: error: no matching function for call to 'format_msg'
  102 |   format_msg(kind, caller, msg_buf, msg_buf + sizeof(msg_buf));
      |   ^~~~~~~~~~
/b/f/w/src/git/out/llvm-project/compiler-rt/lib/ubsan_minimal/ubsan_minimal_handlers.cpp:37:13:
note: candidate function not viable: requires 5 arguments, but 4 were
provided
   37 | static void format_msg(const char *kind, uintptr_t caller,
      |             ^          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   38 |                        const uintptr_t *address, char *buf,
const char *end) {

This change adds the address argument to abort_with_message just like __ubsan_report_error_fatal so it can be passed to format_msg.


Full diff: https://github.com/llvm/llvm-project/pull/152419.diff

1 Files Affected:

  • (modified) compiler-rt/lib/ubsan_minimal/ubsan_minimal_handlers.cpp (+5-5)
diff --git a/compiler-rt/lib/ubsan_minimal/ubsan_minimal_handlers.cpp b/compiler-rt/lib/ubsan_minimal/ubsan_minimal_handlers.cpp
index b1f4eab26de0e..2295162021f85 100644
--- a/compiler-rt/lib/ubsan_minimal/ubsan_minimal_handlers.cpp
+++ b/compiler-rt/lib/ubsan_minimal/ubsan_minimal_handlers.cpp
@@ -97,15 +97,15 @@ SANITIZER_INTERFACE_WEAK_DEF(void, __ubsan_report_error_fatal, const char *kind,
 
 #if defined(__ANDROID__)
 extern "C" __attribute__((weak)) void android_set_abort_message(const char *);
-static void abort_with_message(const char *kind, uintptr_t caller) {
+static void abort_with_message(const char *kind, uintptr_t caller, const uintptr_t *address) {
   char msg_buf[128];
-  format_msg(kind, caller, msg_buf, msg_buf + sizeof(msg_buf));
+  format_msg(kind, caller, address, msg_buf, msg_buf + sizeof(msg_buf));
   if (&android_set_abort_message)
     android_set_abort_message(msg_buf);
   abort();
 }
 #else
-static void abort_with_message(const char *kind, uintptr_t caller) { abort(); }
+static void abort_with_message(const char *kind, uintptr_t caller, const uintptr_t *address) { abort(); }
 #endif
 
 #if SANITIZER_DEBUG
@@ -132,7 +132,7 @@ void NORETURN CheckFailed(const char *file, int, const char *cond, u64, u64) {
   INTERFACE void __ubsan_handle_##name##_minimal_abort() {                     \
     uintptr_t caller = GET_CALLER_PC();                                        \
     __ubsan_report_error_fatal(kind, caller, nullptr);                         \
-    abort_with_message(kind, caller);                                          \
+    abort_with_message(kind, caller, nullptr);                                 \
   }
 
 #define HANDLER(name, kind)                                                    \
@@ -149,7 +149,7 @@ void NORETURN CheckFailed(const char *file, int, const char *cond, u64, u64) {
       const uintptr_t address) {                                               \
     uintptr_t caller = GET_CALLER_PC();                                        \
     __ubsan_report_error_fatal(kind, caller, &address);                        \
-    abort_with_message(kind, caller);                                          \
+    abort_with_message(kind, caller, nullptr);                                 \
   }
 
 // A version of a handler that takes a pointer to a value.

Copy link

github-actions bot commented Aug 7, 2025

✅ With the latest revision this PR passed the C/C++ code formatter.

@vitalybuka vitalybuka merged commit d9f9064 into llvm:main Aug 7, 2025
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants